const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("Vote", function () {
    it("Vote test", async function () {
        const Vote = await ethers.getContractFactory("Vote");
        const vote = await Vote.deploy(1647694221);
        await vote.deployed();
        console.log("address: ", await vote.address);
        console.log("endTime: ", await vote.endTime());

        // 设置候选人
        await vote.setCandidates("张三", "0x2D90A171c62A0D2033d3aED05a1DF2AEd2815E5b");
        await vote.setCandidates("李四", "0x256EAc5e66d8B84e27461366C32fd2f4b4fF76e7");
        await vote.setCandidates("王五", "0xf57194cf32ea60d9f69EC1B15067c3A867252FdC");

        // 查看数量
        console.log("count: ", await vote.getCandidateLength());

        // 投票 并查看总数
        await vote.votesToCandidate(0);
        console.log("votes: ", await vote.getCandidateVotes(0));
        console.log("votes: ", await vote.getTotalVotes());
    });
});
